package com.cskaoyan.bean.basebean;

import com.github.pagehelper.PageInfo;
import lombok.Data;

import java.util.List;

@Data
public class BasePageData<T> {
    Integer limit;
    Integer page;
    Integer pages;
    Integer total;
    List<T> list;

    public static <T> BasePageData ok(List<T> list) {
        PageInfo<T> pageInfo = new PageInfo<>(list);

        BasePageData<T> basePageData = new BasePageData<>();
        basePageData.setPage(pageInfo.getPageNum());
        basePageData.setLimit(pageInfo.getPageSize());
        basePageData.setPages(pageInfo.getPages());
        basePageData.setTotal((int) pageInfo.getTotal());
        basePageData.setList(list);

        return basePageData;
    }
}
